<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title></title>
		<link rel="stylesheet" type="text/css"
			href="${contextPath}/resource/css/default.css" />
		<link href="${contextPath}/resource/css/css.css" rel="stylesheet" type="text/css" />
		<script src="${contextPath}/resource/js/index.js"></script>
		<script src="${contextPath}/resource/js/menu.js"></script>
		<script type="text/javascript" src="${contextPath}/resource/tree/jquery-1.4.2.js"></script>
		<script language="javascript">
$(document).ready(function() {
  $('.edit').hide();
  $('.restore').hide();
  $('.edit_click').bind("click",function() {
        $(this).parent().parent().parent().parent().parent().siblings().filter('.edit').slideToggle(100);
  });
$(".edit_click").toggle(function() { 
		var aaa = $(this).parent().parent().parent().parent().parent().siblings().filter('.dashed_text').children('td').text();
		$(this).parent().parent().parent().parent().parent().siblings().filter('.edit').children().find('.text_line').append(aaa);
}, function(event) { 
		$(this).parent().parent().parent().parent().parent().siblings().filter('.edit').children().find('.text_line').text('');
}); 
/*  $(".edit_click").click(function(){
		var aaa = $(this).parent().parent().parent().parent().parent().siblings().filter('.dashed_text').children('td').text();
		$(this).parent().parent().parent().parent().parent().siblings().filter('.edit').children().find('.text_line').append(aaa);
  });*/
  $('.restore_click').bind("click",function() {
        $(this).parent().parent().parent().parent().parent().siblings().filter('.restore').slideToggle(80);
  });
});
</script>
		<script>
function to_delete(id){
	var flag=confirm("确定要删除吗？");
	if(flag==true){
		window.location.href="${contextPath}/msg/messageBoardAction_delete.do?boardId="+id+"";
	}
	else{
		return false;
	}
}
function to_delete1(id){
	var flag=confirm("确定要删除吗？");
	if(flag==true){
		window.location.href="${contextPath}/msg/messageBoardAction_delReply.do?answerId="+id+"";
	}
	else{
		return false;
	}
}
//回复
function addAnswer(id){
		var content=$('#add'+id+'').val();
		if(getLength(content)<=0){
			alert("内容不能为空");
			return false;
		}
		if(getLength(content)>1000){
			alert("内容不超过1000个字符(500个汉字)");
			return false;
		}
		else{
		    $('#hidBoardId').val(id);
			$('#hidAnswerContent').val(content);
		    var url="${contextPath}/msg/messageBoardAction_addReply.do";
		    document.all.feedbackForm.action = url;
		    document.all.feedbackForm.submit();
		}
	}
	function updateAnswer(id){
		var content=$('#update'+id+'').val();
		if(getLength(content)<=0){
			alert("内容不能为空");
			return false;
		}
		if(getLength(content)>1000){
			alert("内容不超过1000个字符(500个汉字)");
			return false;
		}
		else{
			$('#hidAnswerId').val(id);
			$('#hidAnswerContent').val(content);
			$('#feedbackForm').attr("action","${contextPath}/msg/messageBoardAction_editReply.do");
			var url="${contextPath}/msg/messageBoardAction_editReply.do";
			document.all.feedbackForm.action = url;
			document.all.feedbackForm.submit();
		}
		
	}
	function getLength(str) {
		if (str == null || str == "") {
			return 0;
		} else {
			var len = str.length;
			var reLen = 0;
			for ( var i = 0; i < len; i++) {
				if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
					reLen += 2;
				} else {
					reLen++;
				}
			}
			return reLen;
		}
	}
</script>
	</head>
	<body id="jump">
		<table class="menu_table">
			<tr>
				<th>手机留言管理</th>
			</tr>
		</table>
		<div class="listtable">
		<div class="secondDiv">
		<form id="feedbackForm" name="feedbackForm" method="post">
		<table class="solid-bottom" id="js_table">
			
			<s:iterator value="page.list" var="messageBoard">
				<tr>
									<td width="10px"></td>
									<td width="70px" height="50px" align="center"><span
										class="STYLE10"></span></td>
									<td>
									<table border="0" cellspacing="0" cellpadding="0" align="left"
										 width="100%">
										<tr>
											<td height="2px" width="10px"></td>
										</tr>
										<tr>
											<td></td>
											<td align="right">
											<table width="100%" cellspacing="0" cellpadding="0" border="0"></table><div><br /></div><table width="100%" cellspacing="0" cellpadding="0" border="0"> 
												<tr> 
													<td height="20" align="left" class="STYLE10">操作员：${messageBoard.userName} 
													&nbsp;&nbsp;&nbsp;&nbsp;发表于：${messageBoard.lbSj}</td> 
													<td height="30"> 
													<table width="50" cellspacing="0" cellpadding="0" border="0" align="right"> 
														<tr> 
															<td height="14" width="14"><img height="14" width="14" src="${contextPath}/resource/img/11.gif" /></td> 
															<td width="32" onclick="to_delete('${messageBoard.lbId}');" class="delete">&nbsp;<a href="#">删除</a>&nbsp;</td> 
															<td width="5"></td> 
														</tr> 
													</table> 
													</td> 
												</tr> 
											</table>
											</td>
											<td width="10px"></td>
										</tr>
										<tr>
											<td></td>
											<td class="font"><span>${messageBoard.lbLr}</span></td>
											<td></td>
										</tr>
										<c:forEach items="${messageBoard.messageReplies}" var="messageReply"  > 
										<c:if test="${not empty messageReply}">

											<tr>
												<td height="10px"></td>
											</tr>
											<tr>
												<td></td>
												<td class="dashed">
												<table border="0" cellpadding="0" cellspacing="0"
													width="100%">
													<tr>
														<td height="20px" class="STYLE10">操作员${messageReply.userName}&nbsp;&nbsp;&nbsp;&nbsp;发表于：${messageReply.lhSj}</td>
													</tr>
													<tr>
														<td height="20px" class="STYLE10">回复：</td>
													</tr>
													<tr class="dashed_text">
														<td colspan="2"><span>${messageReply.lhLr}</span></td>
													</tr>
													<tr>
														<td height="30px">
														<table border="0" align="right" cellpadding="0"
															cellspacing="0">
															<tr>
																<td width="14px"><img
																	src="${contextPath}/resource/img/edt.gif"
																	width="16" height="16" /></td>
																<td class="edit_click">&nbsp;<a href="#">编辑</a>&nbsp;</td>
																<td width="2px">|&nbsp;</td>
																<td width="14px"><img
																	src="${contextPath}/resource/img/11.gif"
																	width="14" height="14" /></td>
																<td onclick="to_delete1(${messageReply.lhId});" class="delete">&nbsp;<a href="#">删除</a>&nbsp;</td>
															</tr>
														</table>
														</td>
													</tr>
													<tr class="edit">
														<td>
														<table border="0" cellpadding="0" cellspacing="0"
															width="100%">
															<tr>
																<td><textarea rows="5" class="text_line"
																	id="update${messageReply.lhId}"></textarea></td>
															</tr>
															<tr>
																<td height="5px"></td>
															</tr>
															<tr>
																<td align="left"><input type="button" class="btn4"
																	value="提 交" onclick="updateAnswer(${messageReply.lhId});" /></td>
															</tr>
														</table>
														</td>
													</tr>
												</table>
												</td>
												<td></td>
											</tr>
											</c:if>
										</c:forEach>
										<tr>
											<td height="10px"></td>
										</tr>
										<tr>
											<td></td>
											<td align="right">
											<table border="0" cellpadding="0" cellspacing="0"
												width="100%">
												<tr>
													<td height="30px" class="ling_top" colspan="3">
													<table border="0" align="right" cellpadding="0"
														cellspacing="0" width="53px">
														<tr>
															<td width="14px"><img
																src="${contextPath}/resource/img/edt.gif"
																width="16" height="16" /></td>
															<td width="32px" class="restore_click">&nbsp;<a href="#">回复</a>&nbsp;</td>
															<td width="5px"></td>
														</tr>
													</table>
													</td>
												</tr>
												<tr class="restore">
													<td>
													<table border="0" cellpadding="0" cellspacing="0"
														width="100%">
														<tr>
															<td width="10px"></td>
															<td><textarea rows="5" class="text_line1"
																id="add${messageBoard.lbId}"></textarea></td>
															<td width="15px"></td>
														</tr>
														<tr>
															<td height="5px"></td>
														</tr>
														<tr>
															<td width="10px"></td>
															<td align="left" colspan="2"><input type="button"
																class="btn4" value="回 复"
																onclick="addAnswer(${messageBoard.lbId});" /></td>
														</tr>
													</table>
						</td>
												</tr>
												<tr>
													<td height="10px"></td>
												</tr>
											</table>
											</td>
											<td width="10px"></td>
										</tr>

									</table>
									</td>
									<td width="10px"></td>
								</tr>
								<tr>
									<td height="10px"></td>
								</tr>
			</s:iterator>
		</table>
		<s:hidden name="answerContent" id="hidAnswerContent" ></s:hidden>
		<s:hidden name="boardId" id="hidBoardId" ></s:hidden>
		<s:hidden name="answerId" id="hidAnswerId" ></s:hidden>
		</form>
			<table class="button_table">
				<tr>
					<td  width="20%" align="left">
					<div style="">
						
					</div>
					</td>
					<td >
						<div class="pages">
							${pageLinkList}
						</div>
					</td>
				</tr>
			</table>
			</div>
			</div>
	</body>
</html>